package com.isyscore.os.flinksql.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author wany
 * 状态后端的类型
 */
@Getter
public enum StateBackendEnum {
    /**
     * 内存检查点
     */
    MEMORY("0"),
    /**
     * 文件检查点
     */
    FILE("1");

    private final String type;

    StateBackendEnum(String type) {
        this.type = type;
    }

    public static StateBackendEnum getStateBackend(String stateBackendType) {
        if (StringUtils.isEmpty(stateBackendType)) {
            return FILE;
        }

        for (StateBackendEnum stateBackendEnum : StateBackendEnum.values()) {
            if (stateBackendEnum.getType().equalsIgnoreCase(stateBackendType.trim())) {
                return stateBackendEnum;
            }

        }
        throw new RuntimeException("stateBackendType值只能是 0 1 2 非法参数值" + stateBackendType);
    }
}
